package databasehandling;

/**
 * HandlerFactory er en singleton, som står for at oprette objekter af de andre
 * Handlerklasser.
 */
public class HandlerFactory {

    private static HandlerFactory instance;

    private AnsatHandler ansatHandler;
    private VareHandler vareHandler;
    private KasseHandler kasseHandler;
    private SalgsHandler salgsHandler;
    private EventHandler eventHandler;
    private StatistikHandler statistikHandler;

    private HandlerFactory() {
        //Does nothing
    }

    /**
     *
     * @return instance of this class. Can never be null.
     */
    public static HandlerFactory getInstance() {
        if (instance == null) {
            instance = new HandlerFactory();
        }
        return instance;
    }

    public StatistikHandler getStatistikHandler() {
        if(statistikHandler == null){
            statistikHandler = new StatistikHandler();
        }
        return statistikHandler;
    }

    public AnsatHandler getAnsatHandler() {
        if (ansatHandler == null) {
            ansatHandler = new AnsatHandler();
        }
        return ansatHandler;
    }

    public SalgsHandler getSalgsHandler() {
        if (salgsHandler == null) {
            salgsHandler = new SalgsHandler();
        }
        return salgsHandler;
    }

    public VareHandler getVareHandler() {
        if (vareHandler == null) {
            vareHandler = new VareHandler();
        }
        return vareHandler;
    }

    public KasseHandler getKasseHandler() {
        if (kasseHandler == null) {
            kasseHandler = new KasseHandler();
        }
        return kasseHandler;
    }

    public EventHandler getEventHandler() {
        if (eventHandler == null) {
            eventHandler = new EventHandler();
        }
        return eventHandler;
    }

}
